package com.ourchem.web.controller.bus;

import java.util.List;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ourchem.common.annotation.Log;
import com.ourchem.common.core.controller.BaseController;
import com.ourchem.common.core.domain.AjaxResult;
import com.ourchem.common.enums.BusinessType;
import com.ourchem.bus.domain.Evaluate;
import com.ourchem.bus.service.IEvaluateService;
import com.ourchem.common.utils.poi.ExcelUtil;
import com.ourchem.common.core.page.TableDataInfo;

/**
 * evaluateController
 * 
 * @author xiYan
 * @date 2023-01-13
 */
@RestController
@RequestMapping("/evaluate/evaluate")
public class EvaluateController extends BaseController
{
    @Autowired
    private IEvaluateService evaluateService;

    /**
     * 查询evaluate列表
     */
    @PreAuthorize("@ss.hasPermi('evaluate:evaluate:list')")
    @GetMapping("/list")
    public TableDataInfo list(Evaluate evaluate)
    {
        startPage();
        List<Evaluate> list = evaluateService.selectEvaluateList(evaluate);
        return getDataTable(list);
    }

    /**
     * 导出evaluate列表
     */
    @PreAuthorize("@ss.hasPermi('evaluate:evaluate:export')")
    @Log(title = "evaluate", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(Evaluate evaluate)
    {
        List<Evaluate> list = evaluateService.selectEvaluateList(evaluate);
        ExcelUtil<Evaluate> util = new ExcelUtil<Evaluate>(Evaluate.class);
        return util.exportExcel(list, "evaluate数据");
    }

    /**
     * 获取evaluate详细信息
     */
    @PreAuthorize("@ss.hasPermi('evaluate:evaluate:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(evaluateService.selectEvaluateById(id));
    }

    /**
     * 新增evaluate
     */
    @PreAuthorize("@ss.hasPermi('evaluate:evaluate:add')")
    @Log(title = "evaluate", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody Evaluate evaluate)
    {
        return toAjax(evaluateService.insertEvaluate(evaluate));
    }

    /**
     * 修改evaluate
     */
    @PreAuthorize("@ss.hasPermi('evaluate:evaluate:edit')")
    @Log(title = "evaluate", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody Evaluate evaluate)
    {
        return toAjax(evaluateService.updateEvaluate(evaluate));
    }

    /**
     * 删除evaluate
     */
    @PreAuthorize("@ss.hasPermi('evaluate:evaluate:remove')")
    @Log(title = "evaluate", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(evaluateService.deleteEvaluateByIds(ids));
    }
}
